package win.timloong.android.carwiki.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import win.timloong.android.carwiki.R;

/**
 * 推荐
 */
public class IndexFragment extends Fragment {

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_index, container, false);
        ViewPager viewPager = (ViewPager) view.findViewById(R.id.index_viewpager);

        final Fragment[] fragments = new Fragment[]{new IndexItemFragment()};
        viewPager.setAdapter(new FragmentPagerAdapter(getChildFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
                return fragments[position];
            }

            @Override
            public int getCount() {
                Log.e("getCount","1");
                return fragments.length;
            }
        });


        return view;
    }
}
